package com.example.springcloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Description: TODO
 * @Author wenlinyu
 * @Date: 2021/4/1 15:58
 * @Version 1.0
 */
@RestController
public class OrderZkController {

    // 单节点访问
    // private static final String PAYMENT_URL = "http://localhost:8001";

    // 集群访问-需要在RestTemplate上开启@LoadBalanced注解实现负载均衡，否则报错：java.net.UnknownHostException: CLOUD-PROVIDER-SERVICE
    private static final String PAYMENT_URL = "http://cloud-provider-payment";

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/consumer/payment/zk")
    public String paymentZk() {
        return restTemplate.getForObject(PAYMENT_URL + "/payment/zk", String.class);
    }
}
